////
//// Source code recreated from a .class file by IntelliJ IDEA
//// (powered by Fernflower decompiler)
////
//package video;
//
//import java.io.ByteArrayInputStream;
//import java.io.ByteArrayOutputStream;
//import java.io.DataInputStream;
//import java.io.DataOutputStream;
//import javax.microedition.lcdui.Alert;
//import javax.microedition.lcdui.AlertType;
//import javax.microedition.lcdui.ChoiceGroup;
//import javax.microedition.lcdui.Command;
//import javax.microedition.lcdui.CommandListener;
//import javax.microedition.lcdui.Display;
//import javax.microedition.lcdui.Displayable;
//import javax.microedition.lcdui.Form;
//import javax.microedition.lcdui.Image;
//import javax.microedition.rms.RecordStore;
//import javax.microedition.rms.RecordStoreException;
//
//public class ListForm extends Form implements CommandListener {
//    private final ChoiceGroup lst = new ChoiceGroup("", 1);
//    private Command connCommand = null;
//    private Command setCommand = null;
//    private Command addCommand = null;
//    private Command delCommand = null;
//    private Command exitCommand = null;
//    private Command backCommand = null;
//    private int nMAX = 25;
//    private int nChannelCount = 0;
//    public ListForm.ChannelInfo[] channelinfo;
//    public int nLanguage = 0;
//    private SettingForm settingForm;
//    private final AboutCanvas parentCanvas;
//    private final Display display;
//    private VideoCanvas videoCanvas;
//
//    public ListForm(AboutCanvas var1, Display var2) {
//        super("");
//        this.parentCanvas = var1;
//        this.display = var2;
//        this.nLanguage = this.parentCanvas.nLanguage;
//        this.channelinfo = new ListForm.ChannelInfo[this.nMAX];
//
//        for(int var3 = 0; var3 < this.nMAX; ++var3) {
//            this.channelinfo[var3] = new ListForm.ChannelInfo();
//        }
//
//        this.loadRecord();
//        Image var6 = null;
//
//        try {
//            var6 = Image.createImage("/camera.png");
//        } catch (Exception var5) {
//            ;
//        }
//
//        if(this.nChannelCount < 1) {
//            this.lst.append("1", var6);
//            this.append(this.lst);
//            this.AddChannel(0);
//            this.nChannelCount = 1;
//        } else {
//            for(int var4 = 0; var4 < this.nChannelCount; ++var4) {
//                this.lst.append(this.channelinfo[var4].strName, var6);
//            }
//
//            this.append(this.lst);
//        }
//
//        if(this.nLanguage == 0) {
//            this.connCommand = new Command("连接", 1, 1);
//            this.setCommand = new Command("设置", 1, 1);
//            this.addCommand = new Command("添加源", 1, 1);
//            this.delCommand = new Command("删除源", 1, 1);
//            this.backCommand = new Command("上一步", 1, 1);
//            this.exitCommand = new Command("退出", 1, 1);
//        } else {
//            this.connCommand = new Command("Connect", 1, 1);
//            this.setCommand = new Command("Set", 1, 1);
//            this.addCommand = new Command("Add", 1, 1);
//            this.delCommand = new Command("Delete", 1, 1);
//            this.backCommand = new Command("Back", 1, 1);
//            this.exitCommand = new Command("Exit", 1, 1);
//        }
//
//        this.addCommand(this.connCommand);
//        this.addCommand(this.setCommand);
//        this.addCommand(this.addCommand);
//        this.addCommand(this.delCommand);
//        this.addCommand(this.backCommand);
//        this.addCommand(this.exitCommand);
//        this.setCommandListener(this);
//    }
//
//    public void commandAction(Command var1, Displayable var2) {
//        int var3;
//        if(var1 == this.connCommand) {
//            if(this.channelinfo[this.lst.getSelectedIndex()].ystno.length() > 0) {
//                var3 = 0;
//                byte[] var4 = new byte[this.channelinfo[this.lst.getSelectedIndex()].ystno.length()];
//                var4 = this.channelinfo[this.lst.getSelectedIndex()].ystno.getBytes();
//
//                for(int var5 = 0; var5 < this.channelinfo[this.lst.getSelectedIndex()].ystno.length(); ++var5) {
//                    if(var4[var5] >= 65 && var4[var5] <= 122) {
//                        var3 = var5;
//                    }
//                }
//
//                try {
//                    this.channelinfo[this.lst.getSelectedIndex()].Ystno = Integer.parseInt(this.channelinfo[this.lst.getSelectedIndex()].ystno.substring(var3 + 1));
//                    this.channelinfo[this.lst.getSelectedIndex()].Group = this.channelinfo[this.lst.getSelectedIndex()].ystno.substring(0, var3 + 1);
//                } catch (Exception var7) {
//                    ;
//                }
//            }
//
//            this.videoCanvas = new VideoCanvas(this, this.display, this.lst.getSelectedIndex());
//            this.display.setCurrent(this.videoCanvas);
//        }
//
//        if(var1 == this.setCommand) {
//            this.settingForm = new SettingForm(this.parentCanvas, this.display, this, this.lst.getSelectedIndex());
//            this.display.setCurrent(this.settingForm);
//        } else if(var1 == this.addCommand) {
//            if(this.nChannelCount >= this.nMAX) {
//                if(this.nLanguage == 0) {
//                    this.display.setCurrent(new Alert("提示:", "不能再添加", (Image)null, AlertType.INFO));
//                } else {
//                    this.display.setCurrent(new Alert("Info:", "Limit", (Image)null, AlertType.INFO));
//                }
//            } else {
//                var3 = this.lst.getSelectedIndex();
//                Image var8 = null;
//
//                try {
//                    var8 = Image.createImage("/camera.png");
//                } catch (Exception var6) {
//                    ;
//                }
//
//                this.lst.insert(var3 + 1, String.valueOf(this.nChannelCount + 1), var8);
//                this.lst.setSelectedIndex(var3, false);
//                this.lst.setSelectedIndex(var3 + 1, true);
//                this.AddChannel(var3);
//            }
//        } else if(var1 == this.delCommand) {
//            System.out.println(this.nChannelCount);
//            if(this.nChannelCount <= 1) {
//                if(this.nLanguage == 0) {
//                    this.display.setCurrent(new Alert("提示:", "最后一个不能删除", (Image)null, AlertType.INFO));
//                } else {
//                    this.display.setCurrent(new Alert("Info:", "can\'t delete the last one", (Image)null, AlertType.INFO));
//                }
//            } else {
//                var3 = this.lst.getSelectedIndex();
//                this.lst.delete(var3);
//                if(var3 == 0) {
//                    this.lst.setSelectedIndex(var3, true);
//                } else {
//                    this.lst.setSelectedIndex(var3 - 1, true);
//                }
//
//                this.DeleteChannel(var3);
//            }
//        } else if(var1 == this.backCommand) {
//            this.saveRecord();
//            this.display.setCurrent(this.parentCanvas);
//        } else if(var1 == this.exitCommand) {
//            this.saveRecord();
//            this.parentCanvas.exit();
//        }
//
//    }
//
//    public void loadRecord() {
//        try {
//            byte[] var1 = new byte[4];
//            RecordStore var2 = RecordStore.openRecordStore("ChannelCountRS", true);
//            if(var2.getNumRecords() == 1) {
//                var1 = var2.getRecord(1);
//            }
//
//            var2.closeRecordStore();
//            this.nChannelCount = var1[0];
//            if(this.nChannelCount > this.nMAX) {
//                this.nChannelCount = this.nMAX;
//            }
//
//            if(this.nChannelCount > 0) {
//                for(int var3 = 0; var3 < this.nChannelCount; ++var3) {
//                    var2 = RecordStore.openRecordStore("ChannelInfoRS" + String.valueOf(var3), true);
//                    if(var2.getNumRecords() == 10) {
//                        this.channelinfo[var3].strName = this.BytesToString(var2.getRecord(1));
//                        this.channelinfo[var3].ystno = new String(var2.getRecord(2));
//                        this.channelinfo[var3].SvrAddr = new String(var2.getRecord(3));
//                        var1 = var2.getRecord(4);
//                        this.channelinfo[var3].SvrPort = var1[0] & 255 | (var1[1] & 255) << 8;
//                        this.channelinfo[var3].User = new String(var2.getRecord(5));
//                        var1 = var2.getRecord(7);
//                        if(var1[0] == 1) {
//                            this.channelinfo[var3].IsSv = true;
//                            this.channelinfo[var3].Pswd = new String(var2.getRecord(6));
//                        } else {
//                            this.channelinfo[var3].IsSv = false;
//                            this.channelinfo[var3].Pswd = "";
//                        }
//
//                        var1 = var2.getRecord(8);
//                        this.channelinfo[var3].Chnl = var1[0] & 255;
//                        var1 = var2.getRecord(9);
//                        if(var1[0] == 1) {
//                            this.channelinfo[var3].Flsh = true;
//                        } else {
//                            this.channelinfo[var3].Flsh = false;
//                        }
//
//                        var1 = var2.getRecord(10);
//                        if(var1[0] == 1) {
//                            this.channelinfo[var3].IsYST = true;
//                        } else {
//                            this.channelinfo[var3].IsYST = false;
//                        }
//                    }
//
//                    var2.closeRecordStore();
//                }
//            } else {
//                this.nChannelCount = 0;
//            }
//        } catch (RecordStoreException var4) {
//            ;
//        }
//
//    }
//
//    public void saveRecord() {
//        try {
//            byte[] var1 = new byte[4];
//            var1[0] = (byte)this.nChannelCount;
//            RecordStore var2 = RecordStore.openRecordStore("ChannelCountRS", true);
//            if(var2.getNumRecords() == 1) {
//                var2.setRecord(1, var1, 0, 1);
//            } else {
//                if(var2.getNumRecords() > 0) {
//                    var2.closeRecordStore();
//                    RecordStore.deleteRecordStore("ChannelCountRS");
//                    var2 = RecordStore.openRecordStore("ChannelCountRS", true);
//                }
//
//                var2.addRecord(var1, 0, 1);
//            }
//
//            var2.closeRecordStore();
//
//            for(int var3 = 0; var3 < this.nChannelCount; ++var3) {
//                try {
//                    var2 = RecordStore.openRecordStore("ChannelInfoRS" + String.valueOf(var3), true);
//                    byte[] var4 = this.StringtoBytes(this.channelinfo[var3].strName);
//                    if(var2.getNumRecords() == 10) {
//                        if(this.channelinfo[var3].strName.length() > 0) {
//                            var2.setRecord(1, var4, 0, var4.length);
//                        }
//
//                        if(this.channelinfo[var3].ystno.length() > 0) {
//                            var2.setRecord(2, this.channelinfo[var3].ystno.getBytes(), 0, this.channelinfo[var3].ystno.length());
//                        }
//
//                        if(this.channelinfo[var3].SvrAddr.length() > 0) {
//                            var2.setRecord(3, this.channelinfo[var3].SvrAddr.getBytes(), 0, this.channelinfo[var3].SvrAddr.length());
//                        }
//
//                        var1[0] = (byte)this.channelinfo[var3].SvrPort;
//                        var1[1] = (byte)(this.channelinfo[var3].SvrPort >> 8);
//                        var2.setRecord(4, var1, 0, 2);
//                        if(this.channelinfo[var3].User.length() > 0) {
//                            var2.setRecord(5, this.channelinfo[var3].User.getBytes(), 0, this.channelinfo[var3].User.length());
//                        }
//
//                        if(this.channelinfo[var3].Pswd.length() > 0) {
//                            var2.setRecord(6, this.channelinfo[var3].Pswd.getBytes(), 0, this.channelinfo[var3].Pswd.length());
//                        }
//
//                        if(this.channelinfo[var3].IsSv) {
//                            var1[0] = 1;
//                        } else {
//                            var1[0] = 0;
//                        }
//
//                        var2.setRecord(7, var1, 0, 1);
//                        var1[0] = (byte)this.channelinfo[var3].Chnl;
//                        var2.setRecord(8, var1, 0, 1);
//                        if(this.channelinfo[var3].Flsh) {
//                            var1[0] = 1;
//                        } else {
//                            var1[0] = 0;
//                        }
//
//                        var2.setRecord(9, var1, 0, 1);
//                        if(this.channelinfo[var3].IsYST) {
//                            var1[0] = 1;
//                        } else {
//                            var1[0] = 0;
//                        }
//
//                        var2.setRecord(10, var1, 0, 1);
//                    } else {
//                        if(var2.getNumRecords() > 0) {
//                            var2.closeRecordStore();
//                            RecordStore.deleteRecordStore("SettingRS" + String.valueOf(var3));
//                            var2 = RecordStore.openRecordStore("SettingRS" + String.valueOf(var3), true);
//                        }
//
//                        var2.addRecord(var4, 0, var4.length);
//                        var2.addRecord(this.channelinfo[var3].ystno.getBytes(), 0, this.channelinfo[var3].ystno.length());
//                        var2.addRecord(this.channelinfo[var3].SvrAddr.getBytes(), 0, this.channelinfo[var3].SvrAddr.length());
//                        var1[0] = (byte)this.channelinfo[var3].SvrPort;
//                        var1[1] = (byte)(this.channelinfo[var3].SvrPort >> 8);
//                        var2.addRecord(var1, 0, 2);
//                        var2.addRecord(this.channelinfo[var3].User.getBytes(), 0, this.channelinfo[var3].User.length());
//                        var2.addRecord(this.channelinfo[var3].Pswd.getBytes(), 0, this.channelinfo[var3].Pswd.length());
//                        if(this.channelinfo[var3].IsSv) {
//                            var1[0] = 1;
//                        } else {
//                            var1[0] = 0;
//                        }
//
//                        var2.addRecord(var1, 0, 1);
//                        var1[0] = (byte)this.channelinfo[var3].Chnl;
//                        var2.addRecord(var1, 0, 1);
//                        if(this.channelinfo[var3].Flsh) {
//                            var1[0] = 1;
//                        } else {
//                            var1[0] = 0;
//                        }
//
//                        var2.addRecord(var1, 0, 1);
//                        if(this.channelinfo[var3].IsYST) {
//                            var1[0] = 1;
//                        } else {
//                            var1[0] = 0;
//                        }
//
//                        var2.addRecord(var1, 0, 1);
//                    }
//
//                    var2.closeRecordStore();
//                } catch (RecordStoreException var5) {
//                    ;
//                }
//            }
//        } catch (RecordStoreException var6) {
//            ;
//        }
//
//    }
//
//    public void AddChannel(int var1) {
//        if(this.nChannelCount >= 1) {
//            for(int var2 = this.nChannelCount; var2 > var1; --var2) {
//                this.channelinfo[var2].strName = this.channelinfo[var2 - 1].strName;
//                this.channelinfo[var2].SvrAddr = this.channelinfo[var2 - 1].SvrAddr;
//                this.channelinfo[var2].SvrPort = this.channelinfo[var2 - 1].SvrPort;
//                this.channelinfo[var2].User = this.channelinfo[var2 - 1].User;
//                this.channelinfo[var2].Pswd = this.channelinfo[var2 - 1].Pswd;
//                this.channelinfo[var2].IsSv = this.channelinfo[var2 - 1].IsSv;
//                this.channelinfo[var2].Chnl = this.channelinfo[var2 - 1].Chnl;
//                this.channelinfo[var2].Flsh = this.channelinfo[var2 - 1].Flsh;
//                this.channelinfo[var2].ystno = this.channelinfo[var2 - 1].ystno;
//                this.channelinfo[var2].useystno = this.channelinfo[var2 - 1].useystno;
//                this.channelinfo[var2].IsYST = this.channelinfo[var2 - 1].IsYST;
//                this.channelinfo[var2].Group = this.channelinfo[var2 - 1].Group;
//                this.channelinfo[var2].Ystno = this.channelinfo[var2 - 1].Ystno;
//            }
//
//            this.channelinfo[var1 + 1].strName = String.valueOf(this.nChannelCount + 1);
//            this.channelinfo[var1 + 1].SvrAddr = "127.0.0.1";
//            this.channelinfo[var1 + 1].SvrPort = 9101;
//            this.channelinfo[var1 + 1].User = "abc";
//            this.channelinfo[var1 + 1].Pswd = "123";
//            this.channelinfo[var1 + 1].IsSv = true;
//            this.channelinfo[var1 + 1].Chnl = 1;
//            this.channelinfo[var1 + 1].Flsh = false;
//            this.channelinfo[var1 + 1].ystno = "A0";
//            this.channelinfo[var1 + 1].useystno = true;
//            this.channelinfo[var1 + 1].IsYST = true;
//            this.channelinfo[var1 + 1].Group = "A";
//            this.channelinfo[var1 + 1].Ystno = 0;
//        } else {
//            this.channelinfo[var1].strName = String.valueOf(this.nChannelCount + 1);
//            this.channelinfo[var1].SvrAddr = "127.0.0.1";
//            this.channelinfo[var1].SvrPort = 9101;
//            this.channelinfo[var1].User = "abc";
//            this.channelinfo[var1].Pswd = "123";
//            this.channelinfo[var1].IsSv = true;
//            this.channelinfo[var1].Chnl = 1;
//            this.channelinfo[var1].Flsh = false;
//            this.channelinfo[var1].ystno = "A0";
//            this.channelinfo[var1].useystno = true;
//            this.channelinfo[var1].IsYST = true;
//            this.channelinfo[var1].Group = "A";
//            this.channelinfo[var1].Ystno = 0;
//        }
//
//        ++this.nChannelCount;
//    }
//
//    public void DeleteChannel(int var1) {
//        for(int var2 = var1; var2 < this.nChannelCount; ++var2) {
//            this.channelinfo[var2].strName = this.channelinfo[var2 + 1].strName;
//            this.channelinfo[var2].SvrAddr = this.channelinfo[var2 + 1].SvrAddr;
//            this.channelinfo[var2].SvrPort = this.channelinfo[var2 + 1].SvrPort;
//            this.channelinfo[var2].User = this.channelinfo[var2 + 1].User;
//            this.channelinfo[var2].Pswd = this.channelinfo[var2 + 1].Pswd;
//            this.channelinfo[var2].IsSv = this.channelinfo[var2 + 1].IsSv;
//            this.channelinfo[var2].Chnl = this.channelinfo[var2 + 1].Chnl;
//            this.channelinfo[var2].Flsh = this.channelinfo[var2 + 1].Flsh;
//            this.channelinfo[var2].ystno = this.channelinfo[var2 + 1].ystno;
//            this.channelinfo[var2].useystno = this.channelinfo[var2 + 1].useystno;
//            this.channelinfo[var2].IsYST = this.channelinfo[var2 + 1].IsYST;
//            this.channelinfo[var2].Group = this.channelinfo[var2 + 1].Group;
//            this.channelinfo[var2].Ystno = this.channelinfo[var2 + 1].Ystno;
//        }
//
//        --this.nChannelCount;
//    }
//
//    public void refreshlst(int var1) {
//        Image var2 = null;
//
//        try {
//            var2 = Image.createImage("/camera.png");
//        } catch (Exception var4) {
//            ;
//        }
//
//        this.lst.set(var1, this.channelinfo[var1].strName, var2);
//    }
//
//    public byte[] StringtoBytes(String var1) {
//        byte[] var2 = (byte[])null;
//
//        try {
//            ByteArrayOutputStream var3 = new ByteArrayOutputStream();
//            DataOutputStream var4 = new DataOutputStream(var3);
//            var4.writeUTF(var1);
//            var2 = var3.toByteArray();
//            var3.close();
//            var4.close();
//        } catch (Exception var5) {
//            var5.printStackTrace();
//        }
//
//        return var2;
//    }
//
//    public String BytesToString(byte[] var1) {
//        ByteArrayInputStream var2 = new ByteArrayInputStream(var1);
//        DataInputStream var3 = new DataInputStream(var2);
//        String var4 = "";
//
//        try {
//            var4 = var3.readUTF();
//            var2.close();
//            var3.close();
//        } catch (Exception var6) {
//            var6.printStackTrace();
//        }
//
//        return var4;
//    }
//
//    public class ChannelInfo {
//        public String strName = "";
//        public String SvrAddr = "127.0.0.1";
//        public int SvrPort = 9101;
//        public String User = "abc";
//        public String Pswd = "123";
//        public boolean IsSv = true;
//        public int Chnl = 1;
//        public boolean Flsh = false;
//        public String ystno = "A0";
//        public boolean useystno = true;
//        public boolean IsYST = true;
//        public String Group = "A";
//        public int Ystno = 0;
//
//        public ChannelInfo() {
//        }
//    }
//}
